#pragma once

#include <string>
#include <vector>
#include <math.h>

//实用工具包
struct Util
{
    static void StringSplit(const std::string &str, const std::string &SEP, int SEP_LEN, std::vector<std::string> &result)
    {
        //1 + 2
        int start = 0;
        while(start < str.size())
        {
            int pos = str.find(SEP, start);

            if(pos == std::string::npos) break; //只剩最后一个数字了

            result.push_back(str.substr(start, pos - start));
            start = pos + SEP_LEN;
        }

        if(start < str.size()) result.push_back(str.substr(start));
    }

    static int StrToInt(const std::string &str)
    {
        //字符串转为数字
        int n = 0;
        int val = 0;    //10 的次方

        auto rit = str.rbegin();
        while(rit != str.rend())
        {
            n += (*rit - '0') * pow(10, val++);
            ++rit;
        }

        return n;
    }
};
